package org.example.code.test2025.one_month;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;

/**
 * @Title: test0108
 * @Author yxy
 * @Package org.example.code.test2025.one_month
 * @Date 2025/1/8 17:49
 * @description:
 */
public class test0108 {
    public int reverse(int x) {
        int INT_MIN = -2147483648;
        int INT_MAX = 2147483647;
        int result = 0;
        int f = x > 0 ? 1 : -1;
        x = Math.abs(x);
        while (x > 0) {
            int digit = x % 10;
            x /= 10;
            if (result > INT_MAX / 10 || (result == INT_MAX / 10 && digit > 7)) {
                return 0;
            }
            if (result < INT_MIN / 10 || (result == INT_MIN / 10 && digit < -8)) {
                return 0;
            }
            result = result * 10 + digit;
        }
        return result * f;
    }

    public static void main(String[] args) {
        test0108 test = new test0108();
        System.out.println(test.reverse(1534236469));
    }
}
